package prv.ljw.boot.tasks;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by carry on 2017/3/1.
 */
@Component
public class ShowTimeTask {

    private final Logger logger = LoggerFactory.getLogger(ShowTimeTask.class);

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Scheduled(fixedDelay = 1000)
    public void showNowTime() throws InterruptedException {
        logger.info("现在时间：" + dateFormat.format(new Date()));
        Thread.sleep(3000);
    }

    @Scheduled(fixedDelay = 1000)
    public void showNowTimeTwo() throws InterruptedException {
        logger.info("现在时间2：" + dateFormat.format(new Date()));
        Thread.sleep(3000);
    }
}
